import router from './index'
import store from '../store'

router.beforeEach((to, from, next) => {
	var isAuthenticated = store.getters.isAuthenticated
	if (to.name !== 'Login' && !isAuthenticated) next({
		name: 'Login'
	})
	else {
		// 校验用户是否登录失效
		// if  登录失效 去登陆
		// else next()
		if (to.matched.length > 1) {
			console.log(to.matched)
			store.dispatch('setmenu', to.matched)
		}
		store.dispatch('setRouter')
		next()
	}
})

// router.afterEach((to, from) => {
//   // ...
// })
